package hot100;

import java.util.HashMap;
import java.util.Map;

/**
 * @author aodre , QQ : 480029069
 * @date 2023/9/11 16:58
 */
public class lc3 {


    public int solve(String s){
        char[] chars = s.toCharArray();
        Map<Character,Integer> map = new HashMap<>();
        int ans =0 ;
        for(int l = 0, r = 0;r < chars.length;r++){
            if(map.containsKey(chars[r]) && l <= map.get(chars[l])){
                l = map.get(chars[r]) + 1;
            }
            map.put(chars[r],r);
            ans = Math.max(ans,r - l + 1);
        }
        return ans;
    }



}
